#include <iostream>
#include <string>
using namespace std;

class CStudent {
		unsigned long reg_num;
		string name;
		double ms, es, cs;
	public:
		double sum();
		double average();
		void printf();
		void get_reg_num();
		void set_stu_inf(string r, string n, double m, double e, double c);
};

double CStudent::sum() {
	return ms + es + cs;
}

double CStudent::average() {
	return (ms + es + cs) / 3;
}

void CStudent::printf() {
	cout << reg_num << "," << name << "," << ms << "," << es << "," << cs << "," << endl;
}

void CStudent::get_reg_num() {
	cout << reg_num << endl;
}

void CStudent::set_stu_inf(string r, string n, double m, double e, double c) {
	string reg_num(r);
	string name(n);
	double ms(m);
	double es(e);
	double cs(c);
}

int main() {
	int n;
	cin >> n;
	CStudent *stu = new CStudent[n];
	for (int i = 0; i < n; i++) {
		unsigned long reg_num;
		string name;
		double ms;
		double es;
		double cs;
		cin >> reg_num >> name >> ms >> es >> cs;
		stu[i].CStudent(reg_num, name, ms, es, cs);
	}
	for (int i = 0; i < n; i++) {
		cout << stu[i].sum() << " " << stu[i].average() << endl;
	}
	int x = 0;
	for (int i = 1; i < n; i++) {
		stu[i].average() > stu[x].average() ? x = i : x = x;
	}
	stu[x].printf();
	delete[]stu;
	return 0;
}